package com.csdj.wenjun.utils;

import junit.framework.TestResult;

import java.util.Random;
import java.util.UUID;

public class RandomUtil {

    /**
     * 生成token用于登录验证
     * @return
     */
    public static String genToken(){
        String s = UUID.randomUUID().toString();
        return s.replaceAll("-","");
    }
    /**
     * 生成自定义长度的随机字符
     * @param num
     * @return
     */
    public static String getUUID(int num) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "").substring(0, num);
        return uuid;
    }
    public  static String getYQM(int num)  {
        String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        char[] c = s.toCharArray();
        Random random = new Random();
        String id="";
        for( int i = 0; i < num; i ++) {
            id=id+c[random.nextInt(c.length)];
        }
        return id;
    }

    public static void main(String[] args) {
//        System.out.println(testRandom1(8));
    }
}
